package com.youngwang.equal;

import com.google.common.base.Objects;
import com.youngwang.lambda.Person;

/**
 * @author youngwang
 *         Date: 2016/8/31
 */
public class EqualTest {

    public static void main(String[] args){
        // 直接存在内存中的常量里面
        String s ="wang";
        // 指向 s 的引用
        String s1 =  "wang";
        // 生成一个对象放在对象堆里面 引用为 s2
        String s2 = new String("wang");
        // 生成一个对象放在对象堆里面 引用为 s3
        String s3 = new String("wang");
        String s4 = s3;
        Person person = new Person("wang","Yang",23);

        System.out.println(Objects.equal(s,person.getFirstName()));
        System.out.println(Objects.equal(s,s1));
        System.out.println(Objects.equal(s,s2));
        System.out.println(Objects.equal(s2,s3));

        System.out.println(s == s1);
        System.out.println(s == s2);
        System.out.println(s2 == s3);
        System.out.println(s2 == s4);
        System.out.println(s3 == s4);
    }
}
